#include <ctime>
#include <iostream>
#include <fstream>

using namespace std;

void SortingSys(int JUST_WORK[], int JUST_WORK_LGHT) {
	while(JUST_WORK_LGHT--) 	{
		bool CHANGE = false;
		
		for(int i = 0; i < JUST_WORK_LGHT; i++) {
			if(JUST_WORK[i] > JUST_WORK[i + 1]){
				swap(JUST_WORK[i], JUST_WORK[i + 1]);
				CHANGE = true;
			}
		}	
	
		if(CHANGE == false) break;
	}
}

void read_from_file(const char *filename, int a[], int length) {
    ifstream file(filename);

    for(int i=0; i < length; i++)
        file >> a[i];
}

int main()
{
    #define LEN 5000
    int a[LEN];

    read_from_file("m1_sorted.txt",a,LEN);
    unsigned int T_ST =  clock();
    SortingSys(a,LEN);
    unsigned int T_LE_FIN = clock();
    unsigned int T_O = T_LE_FIN - T_ST;
    cout<<"m1_sorted " << T_O << " milliseconds \n";
    
    read_from_file("m2_reverse.txt",a,LEN);
    T_ST =  clock();
    SortingSys(a,LEN);
    T_LE_FIN = clock();
    T_O = T_LE_FIN - T_ST;
    cout<<"m2_reverse " << T_O << " milliseconds \n";
    
    read_from_file("m3_shuffle.txt",a,LEN);
    T_ST =  clock();
    SortingSys(a,LEN);
    T_LE_FIN = clock();
    T_O = T_LE_FIN - T_ST;
    cout<<"m3_shuffle " << T_O << " milliseconds \n";
    
    return 0;
}